package cn.tedu.boot411.controller;

import cn.tedu.boot411.entity.User;
import cn.tedu.boot411.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper mapper;

    @RequestMapping("/reg")
    public int insert(User user){
        User u = mapper.select(user);
        if(u!=null){
            return 2;
        }
        mapper.insert(user);
        return 1;
    }

    @RequestMapping("/login")
    public int select(User user){
        User u = mapper.select(user);
        if(u!=null){
            if(u.getPassword().equals(user.getPassword())){
                return 1;
            }
            return 2;
        }
        return 3;

    }


}
